package com.campus.context;

public class CurrentHolder {

    /**
     * 一个线程可以有多个 ThreadLocal 变量；
     * 每个 ThreadLocal 对应一个键值对；所以get方法和remove无参
     * ThreadLocal 实例本身是 key，设置的值是 value

     */
    public static ThreadLocal<Long> CURRENT_ID = new ThreadLocal<>();

    public static void setCurrentId(Long id) {
        CURRENT_ID.set(id);
    }

    public static Long getCurrentId() {
        return CURRENT_ID.get();
    }

    public static void remove() {
        CURRENT_ID.remove();
    }

}
